local skel = fk.CreateSkill {
    name = "ling_moxuluo",
  }

Fk:loadTranslationTable{
    ["ling_moxuluo"] = "八握剑异界神将.魔虚罗",
    [":ling_moxuluo"] = "你使用牌指定其他角色为目标，或其他角色使用牌指定你为目标时，若此牌和你手牌中的“影”的点数、花色、类型均不同，你可以弃置一张“影”对其造成1点伤害。‌‌",

    ["#ling_moxuluo-ask"] = "八握剑异界神将.魔虚罗：你可以弃置一张“影”对其造成1点伤害。",
}
local checkifdifferent = function(cards,tocheckcard)
    local ret = {}
    for _, cid in ipairs(cards) do

        local card = Fk:getCardById(cid)
        if card.suit ~= tocheckcard.suit and card.number ~= tocheckcard.number and card.type ~= tocheckcard.type then
            table.insert(ret, cid)
        end
    end
    return ret
end
skel:addEffect(fk.TargetConfirmed, {
    anim_type = "offensive",
    can_trigger = function(self, event, target, player, data)
      return target == player and player:hasSkill(skel.name) and data.from and data.from ~= player
    end,
    on_cost = function(self, event, target, player, data)
        local shades = table.filter(player:getCardIds("h"), function(cid)
            local card = Fk:getCardById(cid)
            return card.trueName == "shade"
        end)
        local different = checkifdifferent(shades, data.card)
      if #different > 0 then
        local cards = player.room:askToCards(player, {
            min_num = 1,
            max_num = 1,
    
            pattern = tostring(Exppattern{ id = different }),
            skill_name = skel.name,
            prompt = "#ling_moxuluo-ask",
        })
        if #cards > 0 then
            event:setCostData(self, {cards = cards})
            return true
        end
      end
      return false
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local cards = event:getCostData(self).cards
        if #cards > 0 then
            room:throwCard(cards, skel.name, player, player)
        end
        room:damage{
            to = data.from,
            from = player,
            damage = 1,
            skillName = skel.name,
        }
    end,
  })

  skel:addEffect(fk.TargetSpecified, {
    anim_type = "offensive",
    can_trigger = function(self, event, target, player, data)
      return target == player and player:hasSkill(skel.name) and data.firstTarget and
      table.find(data.use.tos, function(p)
        return p ~= player and not p.dead
      end) 
    end,
    on_cost = function(self, event, target, player, data)
        local shades = table.filter(player:getCardIds("h"), function(cid)
            local card = Fk:getCardById(cid)
            return card.trueName == "shade"
        end)
        local different = checkifdifferent(shades, data.card)
      if #different > 0 then
        local cards = player.room:askToCards(player, {
            min_num = 1,
            max_num = 1,
    
            pattern = tostring(Exppattern{ id = different }),
            skill_name = skel.name,
            prompt = "#ling_moxuluo-ask",
        })
        if #cards > 0 then
            event:setCostData(self, {cards = cards})
            return true
        end
      end
      return false
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local cards = event:getCostData(self).cards
        if #cards > 0 then
            room:throwCard(cards, skel.name, player, player)
        end
        room:damage{
            to = data.from,
            from = player,
            damage = 1,
            skillName = skel.name,
        }
    end,
  })

return skel